/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




package learn.round1B;


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Iterator;
import java.util.Scanner;

/**
 *
 * @author robit
 */
public class PickingUpChick{

    PickingUpChick(){}

    private static Scanner s = null;
    private static PrintWriter o = null;
    /**
    * calculate the answer
    */
    private static String reckon() {
        int N=Int();
        int K=Int();
        int B=Int();
        int T=Int();
        int [] s = new int[N];
        int [] v= new int[N];
        for(int i=0;i<N;i++)s[i]=Int();
        for(int i=0;i<N;i++)v[i]=Int();
        boolean [] reach = new boolean[N];
        for(int i=0;i<N;i++)reach[i]=(s[i]+v[i]*T>=B);
        int swap=0,cumfail=0,count=0;

        for(int i=N-1;i>-1&&count<K;i--){
            if(!reach[i])cumfail++;
            else {
                swap += cumfail;
                count++;
            }
        }
        String ans=(count==K)?swap+"":"IMPOSSIBLE";
        return ans;
    }
    private static void print(String str){
        System.out.print(str);
    }
    private static void println(String str){
        System.out.println(str);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here

        try {
            //String filename="test";
            String prob="B";
            //String filename=prob+"-small-practice";
            String filename=prob+"-large-practice";

            s = new Scanner(
                    new BufferedReader(new FileReader(filename+".in")));
            //s.useLocale(Locale.US);
            o = new PrintWriter(
                    new BufferedWriter(new FileWriter(filename+".out")));

            // Determine input line number
            int lineNums = s.nextInt();

            for (int i = 1; i <= lineNums; i++) {
                o.println("Case #" + i + ": " + reckon());
            }
        } finally {
            s.close();
            o.close();
        }
    }


    private static int Int(){
        return s.nextInt();
    }
    private static long Long(){
        return s.nextLong();
    }
    private static String String(){
        return s.next();
    }

}
